#pragma once

#include <rtl/base.h>

#include "drivers/usbtty.h"

#define PACKET_HEADER_SIZE 16
#define PACKET_HEADER_MAGIC 0x239a

#define PT_COMMAND 1
#define PT_DATA 2
#define PT_CONSOLE 3
#define PT_STATUS 4
#define PT_STATUS_DATA 5
#define PT_SETUP 6
#define PT_ABORT 7

typedef struct _PACKET_HEADER
{
    UINT16 Magic;
    UINT16 Type;
    UINT32 DataLength;
    UINT64 Serial;
} PACKED PACKET_HEADER, *PPACKET_HEADER;

#define AG_STATUS_OK 0
#define AG_STATUS_UNKNOWN_ERROR 1
#define AG_STATUS_SETUP_REQUIRED 2
#define AG_STATUS_UNSUPPORTED_COMMAND 3
#define AG_STATUS_INVALID_ARGUMENT 4
#define AG_STATUS_TOO_MUCH_DATA 5
#define AG_STATUS_INVALID_TRANSFER_SIZE 6
#define AG_STATUS_NO_SUCH_PARTITION 7
#define AG_STATUS_ACCESS_DENIED 8
#define AG_STATUS_TOO_SMALL 9
#define AG_STATUS_TOO_BIG 10

#define AG_CMD_REBOOT 1
#define AG_CMD_ENABLE_CONSOLE 2
#define AG_CMD_DISABLE_CONSOLE 3
#define AG_CMD_PRINT_EFUSE_CFG 4
#define AG_CMD_PRINT_BOOTINFO 5
#define AG_CMD_BOOT_LK 6
#define AG_CMD_SEND_TEE 7
#define AG_CMD_GET_LOGS 8
#define AG_CMD_SEND_LK 9
#define AG_CMD_SEND_MTK_DA 10
#define AG_CMD_BOOT_MTK_DA 11
#define AG_CMD_MMC_INIT 12
#define AG_CMD_MMC_READ 13
#define AG_CMD_MMC_WRITE 14
#define AG_CMD_READ_PT 15
#define AG_CMD_WRITE_PT 16
#define AG_CMD_READ_P 17
#define AG_CMD_WRITE_P 18
#define AG_CMD_MMC_INFO 19
#define AG_CMD_SECPOL_DUMP 20
#define AG_CMD_SECPOL_LOCK 21
#define AG_CMD_SECPOL_UNLOCK 22
#define AG_CMD_RUN_TEST 23
#define AG_CMD_SEND_PL 24
#define AG_CMD_BOOT_PL 25
#define AG_CMD_SEND_ATF 26
#define AG_CMD_ENTER_BOOTROM 29

#define AG_BOOT_MTK_DA_USE_LK (1)

VOID UsbSendStatus(UINT32 Status, PVOID Data, SIZE DataLength);